<template>
	<view :data-theme="themeStyle">
		<view class="container">
			<view class="member-container">
				<view class="member-bg">
					<view class="member-bg-circle" :data-theme="defaultInfo.topStyle == 'default' ? themeStyle : ''"
						:style="{left: (-3000+750)/2 + 'rpx'}">
						<view class="user-section ns-gradient-pages-member-index-index"
							:data-theme="defaultInfo.topStyle == 'default' ? themeStyle : ''"
							:style="{background: defaultInfo.topStyle != 'default' ? defaultInfo.bgColor : '', width: windowWidth+'px', left: (3000-750)/2 + 'rpx'}">
							<view class="bg-img">
								<image :src="defaultBgImg" mode="widthFix"></image>
							</view>
							<view class="user-section-box">
								<view class="user-info-box" v-if="token">
									<view @click="$util.redirectTo('/pages/member/info/info')" class="user-head">
										<image
											:src="memberInfo.headimg ? $util.img(memberInfo.headimg) : $util.getDefaultImage().default_headimg"
											mode="aspectFill"
											@error="memberInfo.headimg = $util.getDefaultImage().default_headimg">
										</image>
									</view>
									<view class="user-box">
										<text class="user-title"
											:style="defaultTextColor">{{ memberInfo.nickname }}</text>
										<view v-if="memberInfo.member_level_name"
											@click="$util.redirectTo('/otherpages/member/level/level')"
											class="user-label">
											<text>{{ memberInfo.member_level_name }}</text>
										</view>
									</view>
								</view>
								<view class="user-info-box no-log" v-if="!token"
									@click="redirectToLink('/pages/member/index/index')">
									<view class="user-head">
										<image :src="$util.getDefaultImage().default_headimg"></image>
									</view>
									<view class="user-box">
										<text class="user-title" :style="defaultTextColor">{{ $lang('login') }}</text>
										<text class="user-desc"
											:style="defaultTextColor">{{ $lang('loginTpis') }}</text>
									</view>
								</view>
								<view @click="$util.redirectTo('/pages/member/info/info')" class="user-set"
									v-if="token">
									<view :style="defaultTextColor" class="iconfont iconshezhi"></view>
								</view>
								<view class="member-sction">
									<view class="sction-item"
										@click="redirectToLink('/otherpages/member/balance/balance')">
										<text class="num"
											:style="defaultTextColor">{{ (parseFloat(memberInfo.balance) + parseFloat(memberInfo.balance_money)).toFixed(2) }}</text>
										<text class="sction-item-name"
											:style="defaultTextColor">{{ $lang('balance') }}</text>
									</view>
									<view class="line"></view>
									<view class="sction-item" @click="redirectToLink('/otherpages/member/point/point')">
										<text class="num"
											:style="defaultTextColor">{{ parseInt(memberInfo.point) }}</text>
										<text class="sction-item-name"
											:style="defaultTextColor">{{ $lang('point') }}</text>
									</view>
									<view class="line"></view>
									<view class="sction-item"
										@click="redirectToLink('/otherpages/member/coupon/coupon')">
										<text class="num" :style="defaultTextColor">{{ couponNum }}</text>
										<text class="sction-item-name"
											:style="defaultTextColor">{{ $lang('coupon') }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="member-body">
					<!-- 订单模块 -->
					<view class="order-section">
						<view class="order-head" @click="redirectToLink('/pages/order/list/list')">
							<text class="order-tit">{{ $lang('allOrders') }}</text>
							<view>
								<text class="order-tip">{{ $lang('seeAllOrders') }}</text>
								<text class="order-more iconfont iconright"></text>
							</view>
						</view>
						<view class="order-body">
							<view class="order-item" @click="redirectToLink('/pages/order/list/list?status=waitpay')">
								<view class="order-icon">
									<text v-if="orderNum.waitPay > 99" class="order-num color-base-bg">99+</text>
									<text v-else-if="orderNum.waitPay > 0"
										class="order-num color-base-bg">{{ orderNum.waitPay }}</text>
									<image :src="$util.img('upload/uniapp/member/index/order/default_order_1.png')"
										mode="aspectFit"></image>
								</view>
								<text class="order-name">{{ $lang('waitPay') }}</text>
							</view>
							<view class="order-item" @click="redirectToLink('/pages/order/list/list?status=waitsend')">
								<view class="order-icon">
									<text v-if="orderNum.readyDelivery > 99" class="order-num color-base-bg">99+</text>
									<text v-else-if="orderNum.readyDelivery > 0"
										class="order-num color-base-bg">{{ orderNum.readyDelivery }}</text>
									<image :src="$util.img('upload/uniapp/member/index/order/default_order_2.png')"
										mode="aspectFit"></image>
								</view>
								<text class="order-name">{{ $lang('readyDelivery') }}</text>
							</view>
							<view class="order-item"
								@click="redirectToLink('/pages/order/list/list?status=waitconfirm')">
								<view class="order-icon">
									<text v-if="orderNum.waitDelivery > 99" class="order-num color-base-bg">99+</text>
									<text v-else-if="orderNum.waitDelivery > 0"
										class="order-num color-base-bg">{{ orderNum.waitDelivery }}</text>
									<image :src="$util.img('upload/uniapp/member/index/order/default_order_3.png')"
										mode="aspectFit"></image>
								</view>
								<text class="order-name">{{ $lang('waitDelivery') }}</text>
							</view>
							<view class="order-item" @click="redirectToLink('/pages/order/activist/activist')">
								<view class="order-icon">
									<text v-if="orderNum.refunding > 99" class="order-num color-base-bg">99+</text>
									<text v-else-if="orderNum.refunding > 0"
										class="order-num color-base-bg">{{ orderNum.refunding }}</text>
									<image :src="$util.img('upload/uniapp/member/index/order/default_order_4.png')"
										mode="aspectFit"></image>
								</view>
								<text class="order-name">{{ $lang('refunding') }}</text>
							</view>
						</view>
					</view>

					<view class="Since-address" :style="backgroundUrl" v-if="is_community_address && token">
						<view class="Since-title">
							<text class="title">我的当前自提点</text>
							<view
								@click="redirectToLink('/otherpages/community/community_choose/community_choose?lat_old='+community_Info.latitude+'&log_old='+community_Info.longitude+'&name='+community_Info.community)">
								<text>切换自提点</text>
								<text class="iconfont iconright"></text>
							</view>
						</view>
						<view class="Since-box">
							<!-- <image :src="$util.img(community_Info.community_img)" mode="aspectFill"></image> -->
							<view class="Since-msg">
								<view class="name-box">
									<text class="Since-title-detail">{{community_Info.community}}</text>
									<text class="Since-status colorGray"
										v-if="community_Info.rest_status==1 && community_Info.status!=3">休息中</text>
									<text class="Since-status colorEed" v-if="community_Info.status==3">未营业</text>
								</view>

								<!--  -->
								<view class="Since-address-size" v-if="distance!=''">
									<text class="iconfont iconweizhi1"></text>距您{{distance}}
								</view>
							</view>
							<view class="Since-num">
								<view class="">粉丝数：<text>{{community_Info.team_count.data}}</text></view>
								<view class="">购买指数：<text>{{community_Info.order_sum}}</text></view>
							</view>
							<view class="Since-addredd-detail">地址:<text>{{community_Info.full_address}}</text></view>
							<view class="Since-info">
								<text class="iconfont iconbaozheng"></text>
								<text class="since-desc-1">如果您购买的商品有任何问题，请直接与购买的门店联系！门店将为您处理，</text>
								<text class="since-desc-2">让您售后无忧！</text>
							</view>
						</view>
					</view>

					<view class="Since-address Since-address-null" :style="backgroundUrl"
						v-if="!is_community_address || !token">
						<view class="Since-title">
							<text class="title">我的当前自提点</text>
							<view @click="redirectToLink('/otherpages/community/community_choose/community_choose')">
								<text>切换自提点</text>
								<text class="iconfont iconright"></text>
							</view>
						</view>
						<view class="Since-box">
							<!-- <image :src="$util.img('upload/uniapp/member/index/null.png')"></image> -->
							<view>您还未选择自提点哦~</view>
						</view>
					</view>

					<view class="help-body">
						<image :src="$util.img('upload/uniapp/member/index/phone.png')"></image>
						<text>帮帮忙热线</text>
						<view class="help-info">
							<view class="help-info-desc">如果您找不到购物的提货门店，</view>
							<view>
								<text class="help-info-action">请致电</text>
								<text class="iconfont icondianhua21" @click="tack_phone(telphone)"></text>
								<text class="help-info-phone" @click="tack_phone(telphone)">{{telphone}}</text>
							</view>
						</view>
					</view>

					<!-- 常用功能模块 -->
					<view class="example-body"
						:style="{ background: defaultInfo.topStyle == 'default' || defaultInfo.menuStyle == 'palace' ? '#fff' : '#f7f7f7' }">
						<view class="example-body-head"
							:class="{'example-tit-palace':defaultInfo.menuStyle != 'palace' && defaultInfo.topStyle != 'default'}">
							<text class="example-tit">常用工具</text>
						</view>
						<uni-grid :column="4" :show-border="false" :square="false"
							v-if="defaultInfo.menuStyle == 'palace' && defaultInfo.topStyle != 'default'">
							<block v-for="(item, index) in defaultInfo.menuList" :key="index">
								<view @click="redirectToLink(item.url)" v-if="menuIsShow(item)">
									<uni-grid-item>
										<image class="image" :src="$util.img(item.img)" mode="aspectFit" />
										<text class="text">{{ item.text }}</text>
										<!-- <text class="text" v-if="item.tag=='fenxiao'">{{ fenxiaoWords.concept + '中心' }}</text> -->
									</uni-grid-item>
								</view>
							</block>
						

							<!-- <block v-if="is_community">
								<view @click="redirectToLink('/otherpages/community/community_leader')">
									<uni-grid-item>
										<image class="image" :src="$util.img('upload/uniapp/member/index/menu/icon7.png')" mode="aspectFit" />
										<text class="text">团长中心</text>
									</uni-grid-item>
								</view>
							</block> -->
							<block v-if="memberInfo.delivery_clerk_id>0">
								<view @click="redirectToLink('/otherpages/community/clerk_delivery')">
									<uni-grid-item>
										<image class="image"
											:src="$util.img('upload/uniapp/member/index/menu/icon8.png')"
											mode="aspectFit" />
										<text class="text">配送单</text>
									</uni-grid-item>
								</view>
							</block>
						</uni-grid>
						<uni-grid :column="4" :show-border="false" :square="false"
							v-if="defaultInfo.topStyle == 'default'">
							<block v-for="(list_item,list_index) in defaultInfo.menuList" :key="list_index">
								<view @click="redirectToLink(list_item.url)"
									v-if="list_item.url!='/otherpages/community/community_leader' && list_item.url!='/otherpages/community/clerk_delivery' && list_item.url!='/otherpages/community/clerk_activist'">
									<uni-grid-item>
										<image class="image" :src="$util.img(list_item.img)" mode="aspectFit" />
										<text class="text">{{list_item.text}}</text>
									</uni-grid-item>
								</view>
								<view @click="redirectToLink('/otherpages/community/community_leader')"
									v-if="is_community && list_item.url=='/otherpages/community/community_leader'">
									<uni-grid-item>
										<image class="image" :src="$util.img(list_item.img)" mode="aspectFit" />
										<text class="text">{{list_item.text}}</text>
									</uni-grid-item>
								</view>
								<block v-if="memberInfo.delivery_clerk_id > 0">
									<view v-if="list_item.url=='/otherpages/community/clerk_delivery'"
										@click="redirectToLink(list_item.url)">
										<uni-grid-item>
											<image class="image" :src="$util.img(list_item.img)" mode="aspectFit" />
											<text class="text">{{list_item.text}}</text>
										</uni-grid-item>
									</view>
									<view v-if="list_item.url=='/otherpages/community/clerk_activist'"
										@click="redirectToLink(list_item.url)">
										<uni-grid-item>
											<image class="image" :src="$util.img(list_item.img)" mode="aspectFit" />
											<text class="text">{{list_item.text}}</text>
										</uni-grid-item>
									</view>
								</block>
							</block>
						</uni-grid>

						<view v-if="defaultInfo.menuStyle != 'palace' && defaultInfo.topStyle != 'default'"
							class="list-style">
							<block v-for="(item, index) in defaultInfo.menuList" :key="index">
								<view class="list-style-item"
									:class="defaultInfo.insertGap == 0 ? 'no-interval' : 'interval'"
									@click="redirectToLink(item.url)" v-if="menuIsShow(item)">
									<image class="image" :src="$util.img(item.img)" mode="aspectFit" />
									<text class="text">{{ item.text }}</text>
									<text class="iconfont iconright"></text>
									<!-- <text class="text" v-if="item.tag=='fenxiao'">{{ fenxiaoWords.concept + '中心' }}</text> -->
								</view>
							</block>
						</view>
					</view>

					<view class="padding-bottom">
						<ns-copy-right></ns-copy-right>
					</view>

					<!-- <view class="bottom_logo" v-if="copyrightLogo != ''">
						<image :src="$util.img('copyrightLogo')" @error="imgError()" mode="widthFix"></image>
					</view>
					<view class="bottom_logo" v-else>
						<image :src="$util.img('upload/uniapp/member/index/logo.png')" mode="widthFix"></image>
					</view> -->
					<view class="service-body">
						<view>
							<image :src="$util.img('upload/uniapp/member/index/icon1.png')" mode="aspectFit"></image>
							<text>便宜有好货</text>
						</view>
						<view>
							<image :src="$util.img('upload/uniapp/member/index/icon2.png')" mode="aspectFit"></image>
							<text>次日16:00自提</text>
						</view>
						<view>
							<image :src="$util.img('upload/uniapp/member/index/icon3.png')" mode="aspectFit"></image>
							<text>售后无忧</text>
						</view>
					</view>
				</view>

				<!-- <view class="padding-bottom">
					<ns-copy-right></ns-copy-right>
				</view> -->

				<ns-login ref="login"></ns-login>
				<loading-cover ref="loadingCover"></loading-cover>
				<!-- 底部tabBar -->
				<diy-bottom-nav type="shop"></diy-bottom-nav>
			</view>
		</view>
		<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
	</view>
</template>

<script>
	import uniGrid from '@/components/uni-grid/uni-grid.vue';
	import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue';
	import diyBottomNav from '@/components/diy-bottom-nav/diy-bottom-nav.vue';
	import toTop from '@/components/toTop/toTop.vue';
	import scroll from '@/common/js/scroll-view.js';
	import nsCopyRight from '@/components/ns-copyright/ns-copyright.vue';
	// import fenxiaoWords from 'common/js/fenxiao-words.js';
	import globalConfig from '@/common/js/golbalConfig.js';

	export default {
		components: {
			uniGrid,
			uniGridItem,
			diyBottomNav,
			toTop,
			nsCopyRight
		},
		data() {
			return {
				token: '',
				memberInfo: {
					balance: 0,
					balance_money: 0,
					point: 0
				},
				couponNum: 0,
				orderNum: {
					waitPay: 0, //待付款
					readyDelivery: 0, //待发货
					waitDelivery: 0, //待收货
					waitEvaluate: 0, // 待评价
					refunding: 0 // 退款中
				},
				isVerification: true,
				copyrightLoad: 0,
				copyrightLogo: '',
				bottom_info: {},
				authInfo: {
					is_verifier: false
				},

				shopTop: false,
				scrollTop: 0,
				shopConfig: null,
				promoterInfo: null,
				withdrawConfig: null,
				fenxiaoBasicsConfig: null,
				defaultInfo: {
					topStyle: 'default',
					bgColor: '#ff454f',
					textColor: '#fff',
					bgImg: '',
					menuList: [],
					insertGap: '0',
					menuStyle: 'palace',
					level: 1
				},
				signState: 1, // 签到是否开启
				evaluateConfig: {
					evaluate_audit: 1,
					evaluate_show: 0,
					evaluate_status: 1
				},
				is_community: false, //是否可以申请团长
				community_type: 0,
				community_Info: {}, //团长信息
				is_community_address: false,
				lat: '',
				log: '',
				distance: '', //距离站点的距离
				telphone: ''
			};
		},
		mixins: [scroll, globalConfig],
		computed: {
			storeToken() {
				return this.$store.state.token;
			},
			defaultBgColor() {
				var val = '';
				if (this.defaultInfo.topStyle != 'default') {
					val = 'background:' + this.defaultInfo.bgColor;
				}
				return val;
			},

			topStyle() {
				var val = '',
					_width = 0;
				if (this.defaultInfo.topStyle != 'default') {
					val = 'background:' + this.defaultInfo.bgColor;
				}

				uni.getSystemInfo({
					success: function(res) {
						_width = res.windowWidth;
					}
				});

				val += 'width:' + _width + 'px';
				val += 'left:' + (1500 - _width) / 2 + 'px';
				return val;
			},
			defaultBgImg() {
				var defaultImg = '';
				if (this.defaultInfo.topStyle != 'default') {
					defaultImg = this.defaultInfo.bgImg ? this.$util.img(this.defaultInfo.bgImg) : '';
				} else {
					defaultImg = this.$util.img('upload/uniapp/member/index/member_bg.png');
				}
				return defaultImg;
			},
			defaultTextColor() {
				var textColor = '';
				if (this.defaultInfo.topStyle != 'default') {
					textColor = 'color:' + this.defaultInfo.textColor + ' !important';
				}
				return textColor;
			},
			windowWidth() {
				let val = 0;
				uni.getSystemInfo({
					success: function(res) {
						val = res.windowWidth;
					}
				});
				return val;
			},
			backgroundUrl() {
				let url = this.$util.img('upload/uniapp/member/index/bg.png');
				var str = 'background:' + 'url(' + url + ') no-repeat 0 0/100%';
				return str;
			}
		},
		watch: {
			storeToken: async function(nVal, oVal) {
				if (this.addonIsExit.membersignin) {
					await this.getSignState();
				}
				await this.getMemberInfo();
				this.getOrderNum();
				this.getCouponNum();
				this.checkIsVerifier();
			}
		},
		onLoad() {
			uni.hideTabBar();

			if (this.addonIsExit.memberwithdraw) {
				this.getWithdrawConfig();
			}
			if (this.addonIsExit.fenxiao) {
				this.getFenxiaoBasicsConfig();
			}
			this.getEvaluateConfig();
			this.getCopy()
		},
		async onReady() {
			if (this.addonIsExit.membersignin) {
				await this.getSignState();
			}
			await this.getDefaultInfo();
			if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
		},
		async onShow() {
			// 刷新多语言
			this.$langConfig.refresh();

			this.token = uni.getStorageSync('token');

			if (uni.getStorageSync('userInfo')) {
				this.memberInfo = uni.getStorageSync('userInfo');
			}
			this.getPhone();
			if (this.token) {
				if (this.addonIsExit.membersignin) {
					await this.getSignState();
				}
				await this.getMemberInfo();

				this.getOrderNum();
				this.getCouponNum();
				this.checkIsVerifier();

				this.lat = ''
				this.log = ''

				// #ifdef MP-WEIXIN
				uni.getLocation({
					type: 'gcj02',
					success: (res) => {
						console.log(res, "uni.getLocation")
						this.lat = res.latitude
						this.log = res.longitude
						this.getCommunity_info()
						this.getCommunity_qualification()
						this.getCommunity()
					},
					fail: (err) => {
						console.log(err, '定位失败')
						this.IPLoca()
						this.getCommunity_qualification()
						this.getCommunity()
					}
				});
				// #endif
				// #ifdef H5
				if (this.lat == '') {
					this.IPLoca()
					this.getCommunity_qualification()
					this.getCommunity()
				}
				// #endif
				setTimeout(() => {
					if (this.lat == '') {
						this.IPLoca()
						this.getCommunity_qualification()
						this.getCommunity()
					}
				}, 500)
			} else {
				this.initInfo();
			}



		},
		methods: {
			IPLoca() {
				this.$api.sendRequest({
					url: '/api/Address/ipLocation',
					success: res => {
						if (res.code >= 0) {
							console.log('IP定位成功')
							this.lat = res.data.location.lat
							this.log = res.data.location.lng
							this.getCommunity_info()
						}
					}
				});
			},
			getPartnerInfo() {
				this.$api.sendRequest({
					url: '/api/member/getPartner',
					success: res => {
						console.log(res);
						if(res.code==0){
							if (res.data.info.status == 0) {
								this.$util.redirectTo('/otherpages/city-partner/city-partner-apply');
							} else {
								this.$util.redirectTo('/otherpages/city-partner/city-partner');
							}
						}else{
							uni.showModal({
								showCancel:false,
								content:res.message ? res.message :'请联系管理员'
							})
						}
						

					}
				})
			},
			//处理图片不存在的错误
			imgError() {
				this.copyrightLogo = 'upload/uniapp/member/index/logo.png'
			},
			getCopy() {
				this.$api.sendRequest({
					url: '/api/config/copyright',
					success: res => {
						console.log(res, 'copyright')
						if (res.code >= 0) {
							this.copyrightLogo = res.data.logo;
						}
					}
				});
			},
			// 单位转化
			conversion_util(e) {
				let _distance = e.distance
				let newDistance = ''
				if (_distance < 1) {
					newDistance = parseFloat(_distance) * 1000 + '米'
				} else {
					newDistance = _distance + '公里'
				}
				return newDistance
			},
			// 获取联系电话
			getPhone() {
				this.$api.sendRequest({
					url: '/api/config/contact',
					success: res => {
						if (res.code >= 0) {
							this.telphone = res.data.telephone;
						}
					}
				});
			},
			// 打电话
			tack_phone(e) {
				uni.makePhoneCall({
					phoneNumber: e
				});
			},
			// 签到是否开启
			async getSignState() {
				var res = await this.$api.sendRequest({
					url: '/api/membersignin/getSignStatus',
					async: false
				});
				if (res.code == 0) {
					this.signState = res.data.is_use;
				}
			},
			async getDefaultInfo() {
				var res = await this.$api.sendRequest({
					url: '/api/diyview/memberindex',
					async: false
				});
				if (res.code == 0) {
					this.defaultInfo.topStyle = res.data.topStyle;
					this.defaultInfo.bgColor = res.data.bgColor;
					this.defaultInfo.textColor = res.data.textColor;
					this.defaultInfo.bgImg = res.data.bgImg;
					this.defaultInfo.menuStyle = res.data.menuStyle;
					this.defaultInfo.menuList = res.data.menuList;
					this.defaultInfo.insertGap = res.data.insertGap;
					this.defaultInfo.level = res.data.level || 1;
				}
			},
			redirectToLink(url) {
				console.log(url, 'redirectToLink')
				// return false;
				if (!uni.getStorageSync('token')) {
					this.$refs.login.open(url);
				} else {
					if (url == '/otherpages/community/community_leader') {
						console.log('团长')
						console.log(this.community_type)
						if (this.community_type == 2) {
							// 拒绝
							this.$util.redirectTo('/otherpages/community/community_apply_err');
							return
						} else if (this.community_type == 0) {
							// 待审核
							this.$util.redirectTo('/otherpages/community/community_applying');
							return
						} else if (this.community_type == 3) {
							// 被冻结
							this.$util.redirectTo('/otherpages/community/community_freeze');
							return
						} else if (this.community_type == 4) {
							// 提交申请
							this.$util.redirectTo('/otherpages/community/community_apply');
							return
						} else {
							// 正常进入
							this.$util.redirectTo(url);
							return
						}
					}
					this.$util.redirectTo(url);
				}
			},

			initInfo() {
				this.token = '';
				this.memberInfo = {
					balance: '0.00',
					balance_money: '0.00',
					point: 0
				};
				this.couponNum = 0;
				this.orderNum = {
					waitPay: 0, //待付款
					readyDelivery: 0, //待发货
					waitDelivery: 0, //待收货
					waitEvaluate: 0, // 待评价
					refunding: 0 // 退款中
				};
				this.authInfo = {
					is_verifier: false
				};
				uni.stopPullDownRefresh();
			},
			// 获取会员基础信息
			async getMemberInfo() {
				let res = await this.$api.sendRequest({
					url: '/api/member/info',
					async: false
				});
				if (res.code >= 0 && res.data) {
					console.log(res.data)
					this.token = uni.getStorageSync('token');
					this.memberInfo = res.data;
					uni.setStorageSync('userInfo', this.memberInfo);
				} else {
					this.token = '';
					this.initInfo();
					uni.removeStorageSync('token');
					uni.removeStorageSync('userInfo');
				}
				// if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				uni.stopPullDownRefresh();
			},
			// 是否能开启申请团长
			getCommunity_qualification() {
				this.$api.sendRequest({
					url: '/api/community/config',
					data: {
						token: this.token
					},
					success: res => {
						if (res.code == 0) {
							console.log(res, '/api/community/config')
							if (res.data.value.is_allow_apply == 1) {
								// 可以申请
								this.is_community = true
							}
						}
					}
				});
			},
			// 团长信息
			getCommunity() {
				this.$api.sendRequest({
					url: '/api/community/getleaderinfo',
					data: {
						token: this.token
					},
					success: res => {
						if (res.code == 0) {
							console.log(res)
							if (res.data == null) {
								this.community_type = 4
							} else {
								this.community_type = res.data.status
							}
						}
					}
				});
			},
			getCommunity_info() {
				this.$api.sendRequest({
					url: '/api/community/getMemberCommunity',
					data: {
						token: this.token,
						longitude: this.log,
						latitude: this.lat
					},
					success: res => {
						console.log(res, '/api/community/getMemberCommunity')
						if (res.data) {
							this.is_community_address = true
							this.community_Info = res.data
							if (this.log && this.lat) {
								this.distance = this.conversion_util(this.community_Info)
							} else {
								this.distance = ''
							}
							// if (uni.getStorageSync('selfLocation')) {
							// 	let selfLocation = uni.getStorageSync('selfLocation')
							// 	if (this.community_Info.longitude) {
							// 		this.distance = this.$util.getDistance(selfLocation.latitude, selfLocation.longitude, this.community_Info
							// 			.latitude, this.community_Info.longitude);
							// 	}
							// } else {
							// 	this.distance = 0
							// }
							let fullAddress = res.data.full_address
							this.community_Info.full_address = fullAddress.replace(/,/g, '')
						} else {
							this.is_community_address = false
						}
					}
				});
			},
			// 下拉刷新
			onPullDownRefresh() {
				if (uni.getStorageSync('token')) this.getMemberInfo();
				else this.initInfo();
			},
			// 订单数量
			getOrderNum() {
				this.$api.sendRequest({
					url: '/api/order/num',
					data: {
						order_status: 'waitpay,waitsend,waitconfirm,waitrate,refunding'
					},
					success: res => {
						if (res.code == 0) {
							this.orderNum.waitPay = res.data.waitpay;
							this.orderNum.readyDelivery = res.data.waitsend;
							this.orderNum.waitDelivery = res.data.waitconfirm;
							this.orderNum.waitEvaluate = res.data.waitrate;
							this.orderNum.refunding = res.data.refunding;
						}
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				});
			},
			// 优惠券数量
			getCouponNum() {
				this.$api.sendRequest({
					url: '/coupon/api/coupon/num',
					success: res => {
						if (res.code == 0) {
							this.couponNum = res.data;
						}
					}
				});
			},
			checkIsVerifier() {
				this.$api.sendRequest({
					url: '/api/verify/checkisverifier',
					success: res => {
						this.authInfo.is_verifier = (res.code == 0);
						this.$forceUpdate();
					}
				});
			},
			jumpLevel() {
				if (uni.getStorageSync('token')) {
					this.$util.redirectTo('/otherpages/member/level/level');
				} else {
					this.$refs.login.open('/pages/member/index/index');
				}
			},
			/**
			 * 获取余额提现配置
			 */
			getWithdrawConfig() {
				this.$api.sendRequest({
					url: '/api/memberwithdraw/config',
					success: res => {
						if (res.code >= 0 && res.data) {
							this.withdrawConfig = res.data;
							this.$forceUpdate();
						}
					}
				});
			},
			/**
			 * 获取分销基本配置
			 */
			getFenxiaoBasicsConfig() {
				this.$api.sendRequest({
					url: '/fenxiao/api/config/basics',
					success: res => {
						if (res.code >= 0) {
							this.fenxiaoBasicsConfig = res.data;
							this.$forceUpdate();
						}
					}
				});
			},
			getEvaluateConfig() {
				this.$api.sendRequest({
					url: '/api/goodsevaluate/config',
					success: res => {
						if (res.code == 0) {
							var data = res.data;
							this.evaluateConfig = data;
						}
					}
				});
			},
			menuIsShow(data) {
				switch (data.tag) {
					case 'fenxiao':
						return this.addonIsExit.fenxiao == 1 && this.fenxiaoBasicsConfig && this.fenxiaoBasicsConfig
							.level > 0;
						break;
					case 'memberwithdraw':
						return this.withdrawConfig && this.withdrawConfig.is_use == 1;
						break;
					case 'membersignin':
						return this.signState == 1;
						break;
					case 'verifier':
						return this.authInfo.is_verifier;
						break;
					default:
						return true;
				}
				return true;
			}
		}
	};
</script>

<style lang="scss">
	@import '../public/css/index.scss';

	/deep/.uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none
	}
</style>
<style scoped>
	/deep/ .reward-popup .uni-popup__wrapper-box {
		background: none !important;
		max-width: unset !important;
		max-height: unset !important;
	}

	/deep/ .example-body .uni-grid-item text {
		font-size: 28rpx;
	}
</style>
